<?php
	require_once("php/connection.php");

	
	if($user)
	{
	register_user();
	//if($error!="") echo '<script type="text/javascript">alert('.$error.');</script>';
	
	
	if($_GET['cat'] == "group")
	{
		if($_GET['action'] == "create")
		{		
			include("php/modules/new_group.php");	
		}
		// coz all these will be called from the sidebar
		/*		
		else if($_GET['action'] == "gausipp" && $_GET['gpid']!= "")
		{
			$gpid = $_GET['gpid'];
			include("php/modules/group.php");
		}
		else if($_GET['action'] == "info" && $_GET['gpid']!= "")
		{
			$gpid = $_GET['gpid'];
			include("php/modules/group_info.php");
		}
		else if($_GET['action'] == "viewall")
		{
			include("php/modules/view_all_circles.php");
		}
		*/
	}
	else if($_GET['cat'] == "invite")
	{		
		include("php/modules/invite.php");
	}
	else if($_GET['cat'] == "invitesent")
	{
		echo '<div class="err_box">Invitations sent! :)</div>';		
		include("php/modules/invite.php");
	}
	
	else if($_GET['cat'] == "search")
	{
		include("php/modules/search_results.php");
	}
	
	else if($_GET['cat'] == "feedback") // for feedback
	{
		if(isset($_GET['action']) && $_GET['action']="contact")
		include("php/modules/contact.php");
		else
		include("php/modules/feedback.php");		
	}
	else if($_GET['cat'] == "profile" && isset($_GET['fbid']))
	{
		$fbid = $_GET['fbid'];
		include("php/modules/profile.php");		
	}
	else if($_GET['cat'] == "msg")
	{
		if(isset($_GET['fbid']))
			$fbid = $_GET['fbid'];
		
		include("php/modules/pms.php");		
	}
	else if($_GET['cat']=="settings")
	{
			include('php/modules/settings.php');
	}
	else  // by default if no other thing is there...
	{
		include('php/modules/home_feed.php'); 
	}
	
	} // the end of if($user) condition
	
	
	else  // for non logged in user
	{
		// list of recognized $GET varaibles
		if( $_GET['cat'] == "search" || $_GET['cat'] == "invite" || $_GET['cat'] == "invitesent" || $_GET['cat'] == "group" || $_GET['cat'] == "profile" || $_GET['cat'] == "settings" || $_GET['cat'] == "msg")
			{
			echo '<div class="err_box small-font">You need to be logged in to access that part. <button onclick=\'window.location = "login.php?action=login";\'>login</button></div>';
			//echo '<script>window.location = "login.php?action=login";</script>';
			}
			
		else if($_GET['cat'] == "feedback") // for feedback
		{
			if(isset($_GET['action']) && $_GET['action']="contact")
			include("php/modules/contact.php");
			else
			include("php/modules/feedback.php");		
		}
		else {			
			include("php/modules/home_page.php");		
		}
		
	}
	

?>